<?php
/**
 * Joomla! 1.5 component jhtraq
 *
 * @version $Id: view.html.php 2010-03-09 08:28:06 svn $
 * @author JHShop
 * @package Joomla
 * @subpackage jhtraq
 * @license GNU/GPL
 *
 * Traq type system for Joomla
 *
 * This component file was created using the Joomla Component Creator by Not Web Design
 * http://www.notwebdesign.com/joomla_component_creator/
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// Import Joomla! libraries
jimport( 'joomla.application.component.view');
class JhtraqViewProperties extends JView {
    function display($tpl = null) {

		$task = JRequest::getCmd('task', 'index');
		$tpl = $this->$task();
		
        parent::display($tpl);
    }
    
    
    public function index() {
    	
    }
	function cancel()
	{
		$this->index();
	}
	
	function index()
	{
		$model =& JhtraqHelper::getModel('jhtraq');
		$this->releases =  $model->getReleases();
		$this->projects = $model->getProjectList();
		$this->versions = $model->getVersionList();
		$this->search = JRequest::getVar('search');
		$this->project = JRequest::getVar('project');
		$this->pagination = $model->getPagination();
		
		
	}
	
	function add()
	{
		$model =& JhtraqHelper::getModel('jhtraq');
		$this->release = $model->getRelease(0);
		$this->projects = $model->getProjectList();
		$this->versions = $model->getVersionList();
		$this->jhshopProds = $this->getJhshopProds();
                $this->ambraTypes = $this->getAmbrasubscriptions();
		return 'form';
	}
	
	function edit()
	{
		$model =& JhtraqHelper::getModel('jhtraq');
		$this->release = $model->getRelease($_POST['cid'][0]);
		$this->projects = $model->getProjectList();
		$this->versions = $model->getVersionList();
		$this->jhshopProds = $this->getJhshopProds();
                $this->ambraTypes = $this->getAmbrasubscriptions();
		return 'form';
	}
	
	function save()
	{
		$detail = $_POST;
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->saveRelease($detail);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=releases", "Releases Updated");
	}
	
	
	function remove()
	{
		$model =& JhtraqHelper::getModel('releases');
		$model->remove($_POST['cid']);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=releases", "Releases Deleted");
	}
}    
